<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2020/12/1
  Time: 9:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    用户:<input type="text" name="name" id="name">
    密码:<input type="text" name="pwd" id="pwd">
    <button type="button" onclick="login()">登录</button>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript">
    function login() {
        var name=$("#name").val();
        var pwd=$("#pwd").val();
        alert(name)
        alert("${pageContext.request.contextPath}/user/login")
        $.ajax({
            url:"${pageContext.request.contextPath}/user/login/"+name+"/"+pwd,
            //data:"name="+name+"&pwd="+pwd,
            type:"get",
            //dataType:"json",
            success:function (data) {
                console.log(data)
                if (data==true){
                    location="vote.jsp"
                }else{
                    alert("错误")
                }
            }
        })
    }
</script>
</body>
</html>
